@import '../../variables.scss';
@import './common.css';

// 添加基础样式，模拟 common.css 的效果
.top-navigation * {
  box-sizing: border-box;
  flex-shrink: 0;
}

.top-navigation {
  width: 3141px;
  height: 80px;
  background: url(http://localhost:8085/static/images/shouye/bg.png);
  background-color: #0a0e13;
  background-size: 100% 100%;
  position: relative;
  
  // 响应式适配 - 基准分辨率为3952x1248
  @media screen and (max-width: 1920px) {
    transform: scale(0.4862); // 1920/3952 ≈ 0.4862
    transform-origin: top left;
  }
  
  @media screen and (max-width: 1080px) {
    transform: scale(0.2733); // 1080/3952 ≈ 0.2733
    transform-origin: top left;
  }
  
  @media screen and (min-width: 5120px) {
    transform: scale(1.2955); // 5120/3952 ≈ 1.2955
    transform-origin: top left;
  }

  // 添加 flex 工具类
  &.flex-col {
    display: flex;
    flex-direction: column;
  }

  // 主题样式
  &.theme-default {
    background: url(http://localhost:8085/static/images/shouye/bg.png);
    background-color: #0a0e13;
  }

  &.theme-dark {
    background-color: #1a1a1a;
    background-image: none;
  }

  &.theme-light {
    background-color: #ffffff;
    background-image: none;
    border-bottom: 1px solid #e8e8e8;

    .nav-item span {
      color: #333333 !important;
    }

    .nav-item:hover span {
      color: #1890ff !important;
    }

    .nav-item.active span {
      color: #1890ff !important;
    }
  }

  &.theme-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-image: none;
  }

  &.theme-custom {
    // 自定义主题，通过props覆盖样式
    background: transparent;
  }

  .nav-container {
    width: 100%;
    height: 53px;
    margin: 8px 0 0 0;
    position: relative;
    z-index: 1;

    // 添加 flex 布局
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 26px;

    // 对齐方式
    &.align-left {
      justify-content: flex-start;
    }

    &.align-center {
      justify-content: center;
    }

    &.align-right {
      justify-content: flex-end;
    }

    &.align-space-between {
      justify-content: space-between;
    }

    &.align-space-around {
      justify-content: space-around;
    }
  }

  .nav-item {
    height: 53px;
    background: url(./tag.png) 100% no-repeat;
    background-size: 100% 100%;
    width: 214px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;

    // 添加 flex 布局用于文字定位
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;

    // 禁用动画
    &.no-animation {
      transition: none;
    }

    // 禁用状态
    &.disabled {
      cursor: not-allowed;
      opacity: 0.5;
      pointer-events: none;
    }

    span {
      width: 112px;
      height: 32px;
      overflow-wrap: break-word;
      color: rgba(255, 255, 255, 0.8);
      font-size: 28px;
      letter-spacing: 2px;
      font-family: PangMenZhengDao;
      font-weight: 400;
      text-align: center;
      white-space: nowrap;
      line-height: 32px;
      margin: 6px 0 0 10px;
    }

    // 图标样式
    .nav-icon {
      font-size: 20px;
      margin-bottom: 4px;
    }

    // 徽章样式
    .nav-badge {
      position: absolute;
      top: -5px;
      right: -5px;
      background: #ff4757;
      color: #fff;
      border-radius: 10px;
      padding: 2px 6px;
      font-size: 12px;
      line-height: 1;
      z-index: 10;
    }

    // 左边距效果，除了第一个
    &:not(:first-child) {
      margin-left: 26px;
    }

    // 悬浮效果
    &:hover:not(.disabled):not(.no-hover) {
      transform: translateY(-1px);

      span {
        color: #ffffff;
      }
    }

    // 激活状态
    &.active {
      background: url(./active.png) 100% no-repeat;
      background-size: 100% 100%;

      span {
        color: #ffffff;
        font-weight: 600;
      }

      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 60%;
        height: 2px;
        background: linear-gradient(90deg, transparent, #3498db, transparent);
        z-index: 2;
      }
    }
  }

  // 响应式媒体查询
  &.responsive {
    // 中等屏幕 (1024px - 1399px)
    @media (max-width: 1399px) and (min-width: 1024px) {
      .nav-container {
        gap: 18px; // 稍微减少间隔
      }

      .nav-item {
        width: 180px;

        span {
          font-size: 24px;
          letter-spacing: 1.5px;
          margin: 12px 0 0 40px;
        }
      }
    }

    // 平板屏幕 (768px - 1023px)
    @media (max-width: 1023px) and (min-width: 768px) {
      height: auto;
      min-height: 80px;

      .nav-container {
        flex-wrap: wrap;
        gap: 15px;
        height: auto;
        min-height: 53px;
        margin: 8px 0 0 10%; // 调整左边距

        &.align-right {
          justify-content: flex-end;
        }

        &.align-center {
          justify-content: center;
        }
      }

      .nav-item {
        width: 160px;

        span {
          font-size: 20px;
          letter-spacing: 1px;
          margin: 12px 0 0 35px;
        }
      }
    }

    // 手机屏幕 (最大 767px)
    @media (max-width: 767px) {
      height: auto;
      min-height: 60px;

      .nav-container {
        justify-content: center !important; // 小屏幕时强制居中
        flex-wrap: wrap;
        gap: 12px;
        height: auto;
        min-height: 40px;
        margin: 8px 0 0 0; // 移除左边距
      }

      .nav-item {
        width: 140px;
        height: 45px;

        span {
          font-size: 18px;
          letter-spacing: 1px;
          margin: 10px 0 0 30px;
        }
      }
    }

    // 超小屏幕 (最大 480px)
    @media (max-width: 480px) {
      .nav-container {
        justify-content: center !important;
        gap: 10px;
        margin: 8px 0 0 0;
      }

      .nav-item {
        width: 120px;
        height: 40px;

        span {
          font-size: 16px;
          letter-spacing: 0.5px;
          margin: 8px 0 0 25px;
        }
      }
    }
  }
}